package com.zwj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zwj.bo.*;
import com.zwj.dto.SelectTeachersQuery;
import com.zwj.entity.UserEntity;
import com.zwj.enums.RoleTypeEnum;
import com.zwj.enums.SexEnum;
import com.zwj.enums.TeacherPositionEnum;
import com.zwj.enums.ValidEnum;
import com.zwj.mapper.UserMapper;
import com.zwj.service.UserService;
import com.zwj.utils.DataCheckUtils;
import com.zwj.utils.DateUtils;
import com.zwj.utils.PaginationUtils;
import com.zwj.utils.TokenUtils;
import com.zwj.vo.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;
import java.util.List;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author zwj
 * @since 2021-07-21
 */
@Service
public class UserServiceImpl implements UserService {
    private final UserMapper userMapper;

    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    //登录
    @Override
    public Result login(UserLoginBo userLoginBo) {
        //数据校验
        DataCheckUtils.isNotBlank(userLoginBo.getUserNo(), "用户账号不能为空!");
        DataCheckUtils.isNotBlank(userLoginBo.getPassword(), "密码不能为空!");
        DataCheckUtils.isNotBlank(userLoginBo.getRoleType(), "用户类型不能为空!");
        DataCheckUtils.isValid(RoleTypeEnum.getEnumValue(userLoginBo.getRoleType()) != null, "用户类型不存在!");
        //以用户类型与账号查询用户信息
        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getUserNo, userLoginBo.getUserNo())
                .eq(UserEntity::getRoleType, userLoginBo.getRoleType());
        UserEntity user = userMapper.selectOne(sectionQueryWrapper);
        //查询结果校验
        if (user == null) {
            return Result.error("账号不存在！");
        }
        if (!user.getDelFlag().equals(ValidEnum.EFFECTIVE.getKey())) {
            return Result.error("用户已停用！");
        }
        //md5加密
//        if(!user.getPassword().equals(DigestUtils.md5DigestAsHex(userLoginBo.getPassword().getBytes(StandardCharsets.UTF_8)))){
//            return Result.error("密码错误！");
//        }
        System.out.println(DigestUtils.md5DigestAsHex(userLoginBo.getPassword().getBytes(StandardCharsets.UTF_8)));
        if (!user.getPassword().equals(userLoginBo.getPassword())) {
            return Result.error("密码错误！");
        }
        //生成token
        String token = TokenUtils.getJwtToken(user.getId().toString(), userLoginBo.getRoleType());
        //修改登录Token
        UserEntity userEntity = new UserEntity();
        userEntity.setLoginToken(token);
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getUserNo, userLoginBo.getUserNo())
                .eq(UserEntity::getRoleType, userLoginBo.getRoleType());
        // 2.根据条件修改对应的参数属性值
        int row = userMapper.update(userEntity, updateWrapper);
        //判断修改结果
        if (row == 0) {
            return Result.error("token保存失败，请联系管理员！");
        }
        return Result.success(new UserLoginVo(token, user.getIsFirstLogin()));
    }

    //获取用户信息
    @Override
    public Result getUserDate(String id) {
        //查询指定id的用户
        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getId, id);
        UserEntity user = userMapper.selectOne(sectionQueryWrapper);
        //判断查询结果
        if (user == null) {
            return Result.error("用户不存在!");
        }
        return Result.success(user);
    }

    //登出
    @Override
    public Result loginout(String id) {
        //修改指定id的用户的Token为空值
        UserEntity userEntity = new UserEntity();
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getId, id).set(UserEntity::getLoginToken, null);
        int row = userMapper.update(userEntity, updateWrapper);
        //判断修改结果
        if (row == 0) {
            return Result.error("登出失败!");
        }
        return Result.success();
    }

    //添加教师
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    public synchronized Result addTeacher(AddTeacherBo addTeacherBo, UserEntity userEntity) {
        //数据校验
        DataCheckUtils.isNotBlank(addTeacherBo.getName(), "教师姓名不能为空!");
        DataCheckUtils.isValid(addTeacherBo.getUserNo().matches("[0-9]{6,16}"), "工号必须为6到16位之间!");
        DataCheckUtils.isValid(addTeacherBo.getIdNo().matches("[0-9]{18}"), "身份证号格式错误!");
        DataCheckUtils.isNotBlank(addTeacherBo.getSex(), "性别不能为空!");
        DataCheckUtils.isValid(SexEnum.getEnumValue(addTeacherBo.getSex()) != null, "性别类型不存在!");
        DataCheckUtils.isValid(addTeacherBo.getMobileNo().matches("^1[3|4|5|7|8][0-9]{9}$"), "手机号码格式错误!");
        DataCheckUtils.isNotBlank(addTeacherBo.getPosition(), "职位不能为空!");
        DataCheckUtils.isValid(TeacherPositionEnum.getEnumValue(addTeacherBo.getPosition()) != null, "职位不存在");
        //查询指定工号、身份证号、手机号是否重复
        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getUserNo, addTeacherBo.getUserNo())
                .or().eq(UserEntity::getMobileNo, addTeacherBo.getMobileNo())
                .or().eq(UserEntity::getIdNo, addTeacherBo.getIdNo()).select(UserEntity::getUserNo, UserEntity::getIdNo, UserEntity::getMobileNo);
        List<UserEntity> users = userMapper.selectList(sectionQueryWrapper);
        //判断查询结果
        if (users.size() != 0) {
            for (UserEntity user : users) {
                DataCheckUtils.isNotValid(user.getUserNo().equals(addTeacherBo.getUserNo()), "工号已存在");
                DataCheckUtils.isNotValid(user.getMobileNo().equals(addTeacherBo.getMobileNo()), "手机号已存在");
                DataCheckUtils.isNotValid(user.getIdNo().equals(addTeacherBo.getIdNo()), "身份证号已存在");
            }
        }
        //插入数据
        UserEntity user = new UserEntity();
        user.setName(addTeacherBo.getName());
        user.setUserNo(addTeacherBo.getUserNo());
        user.setIdNo(addTeacherBo.getIdNo());
        user.setSex(addTeacherBo.getSex());
        user.setDelFlag(ValidEnum.EFFECTIVE.getKey());
        user.setMobileNo(addTeacherBo.getMobileNo());
        user.setRoleType(RoleTypeEnum.TEACHER.getKey());
        user.setPosition(addTeacherBo.getPosition());
        user.setPassword(addTeacherBo.getIdNo().substring(addTeacherBo.getIdNo().length() - 6));
        user.setCreateBy(userEntity.getId());
        user.setCreateTime(DateUtils.getCurrentTime());
        user.setUpdateBy(userEntity.getId());
        user.setUpdateTime(DateUtils.getCurrentTime());
        int row = userMapper.insert(user);
        //判断插入结果
        if (row == 0) {
            return Result.error("添加教师失败");
        }
        return Result.success();
    }

    //修改教师
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    public synchronized Result updaTeacher(UpdateTeacherBo updateTeacherBo, UserEntity userEntity) {
        //数据校验
        DataCheckUtils.isNotBlank(updateTeacherBo.getName(), "教师姓名不能为空!");
        DataCheckUtils.isNotBlank(updateTeacherBo.getId(), "ID不能为空!");
        DataCheckUtils.isValid(updateTeacherBo.getUserNo().matches("[0-9]{6,16}"), "工号必须为6到16位之间!");
        DataCheckUtils.isValid(updateTeacherBo.getIdNo().matches("[0-9]{18}"), "身份证号格式错误!");
        DataCheckUtils.isNotBlank(updateTeacherBo.getSex(), "性别不能为空!");
        DataCheckUtils.isValid(SexEnum.getEnumValue(updateTeacherBo.getSex()) != null, "性别类型不存在!");
        DataCheckUtils.isValid(updateTeacherBo.getMobileNo().matches("^1[3|4|5|7|8][0-9]{9}$"), "手机号码格式错误!");
        DataCheckUtils.isNotBlank(updateTeacherBo.getPosition(), "职位不能为空!");
        DataCheckUtils.isValid(TeacherPositionEnum.getEnumValue(updateTeacherBo.getPosition()) != null, "职位不存在");
        //指定ID查询教师
        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getId, updateTeacherBo.getId()).eq(UserEntity::getRoleType,RoleTypeEnum.TEACHER.getKey())
                .select(UserEntity::getUserNo, UserEntity::getIdNo, UserEntity::getMobileNo,UserEntity::getIsFirstLogin);
        UserEntity user = userMapper.selectOne(sectionQueryWrapper);
        if (user == null) {
            return Result.error("未找到该教师");
        }
        //查询指定工号、身份证号、手机号是否重复
        QueryWrapper<UserEntity> sectionQueryWrapper1 = new QueryWrapper<>();
        sectionQueryWrapper1.lambda().eq(UserEntity::getUserNo, updateTeacherBo.getUserNo())
                .or().eq(UserEntity::getMobileNo, updateTeacherBo.getMobileNo())
                .or().eq(UserEntity::getIdNo, updateTeacherBo.getIdNo()).select(UserEntity::getUserNo, UserEntity::getIdNo, UserEntity::getMobileNo);
        List<UserEntity> users = userMapper.selectList(sectionQueryWrapper1);
        String id=updateTeacherBo.getId();
        String userNo = updateTeacherBo.getUserNo();
        String mobileNo = updateTeacherBo.getMobileNo();
        String idNo = updateTeacherBo.getIdNo();
        //判断查询结果
        if (users.size() != 0) {
            for (UserEntity user1 : users) {
                String userNo1 = user1.getUserNo();
                DataCheckUtils.isNotValid(userNo1.equals(userNo) && !userNo1.equals(user.getUserNo()), "工号已存在");
                String mobileNo1 = user1.getMobileNo();
                DataCheckUtils.isNotValid(mobileNo1.equals(mobileNo)&&!mobileNo1.equals(user.getMobileNo()), "手机号已存在");
                String idNo1 = user1.getIdNo();
                DataCheckUtils.isNotValid(idNo1.equals(idNo)&&!idNo1.equals(user.getIdNo()), "身份证号已存在");}

        }
        UserEntity updateUser = new UserEntity();
        updateUser.setName(updateTeacherBo.getName());
        updateUser.setUserNo(updateTeacherBo.getUserNo());
        updateUser.setIdNo(updateTeacherBo.getIdNo());
        updateUser.setSex(updateTeacherBo.getSex());
        updateUser.setMobileNo(updateTeacherBo.getMobileNo());
        updateUser.setPosition(updateTeacherBo.getPosition());
        if(user.getIsFirstLogin().equals("1")){
            updateUser.setPassword(updateUser.getIdNo().substring(updateUser.getIdNo().length() - 6));
        }
        updateUser.setUpdateBy(userEntity.getId());
        updateUser.setUpdateTime(DateUtils.getCurrentTime());
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getId, updateTeacherBo.getId());
        int row = userMapper.update(updateUser, updateWrapper);
        //判断修改结果
        if (row == 0) {
            return Result.error("编辑教师信息失败");
        }
        return Result.success();
    }

    @Override
    public  Result updateTeacherDelFlag(UpdateTeacherDelFlagBo updateTeacherDelFlagBo, UserEntity userEntity) {
        DataCheckUtils.isNotBlank(updateTeacherDelFlagBo.getId(), "教师id不能为空!");
        DataCheckUtils.isNotBlank(updateTeacherDelFlagBo.getDelFlag(), "当前修改状态不能为空!");
        DataCheckUtils.isValid(ValidEnum.getEnumValue(updateTeacherDelFlagBo.getDelFlag())!=null, "用户状态信息错误!");
        UserEntity updateUser = new UserEntity();
        if(updateTeacherDelFlagBo.getDelFlag().equals(ValidEnum.INVALID.getKey())){
            updateUser.setDelFlag(ValidEnum.EFFECTIVE.getKey());
        }else {
            updateUser.setDelFlag(ValidEnum.INVALID.getKey());
        }
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getId, updateTeacherDelFlagBo.getId()).eq(UserEntity::getDelFlag,updateTeacherDelFlagBo.getDelFlag());
        int row = userMapper.update(updateUser, updateWrapper);
        //判断修改结果
        if (row == 0) {
            return Result.error("编辑教师信息失败");
        }
        return Result.success();
    }

    @Override
    public Result selectTeachers(SelectTeacherBo selectTeacherBo, String id) {
        int number = 1;
        int page = 1;
        if(id==null){
            number = selectTeacherBo.getNumber();
            page = selectTeacherBo.getPage();
            //分页参数是否正确
            DataCheckUtils.isValid(PaginationUtils.isPagingParameters(number, page), "分页参数错误!");
        }
        //查询项目组评分 mybatis
        List<Object> result = userMapper.selectTeachers(new SelectTeachersQuery(PaginationUtils.getPageIndex(page, number),number, selectTeacherBo.getName(), selectTeacherBo.getUserNo(),selectTeacherBo.getIdNo(),selectTeacherBo.getMobileNo(),selectTeacherBo.getDelFlag(),id));
        if(id!=null) {
            int sum = ((List<Integer>) result.get(1)).get(0);
            if(sum==0){
                return Result.error("用户不存在");
            }
            return  Result.success(((List<SelectTeacherVo>) result.get(0)).get(0));
        }
        int sum = ((List<Integer>) result.get(1)).get(0);
        List<SelectTeacherVo> teacherVos = (List<SelectTeacherVo>) result.get(0);
        PaginationDate paginationDate = PaginationUtils.getPaginationDate(number, page, sum);
        //记录总数为0
        if (sum == 0) {
            SelectTeacherVo selectTeacherVo = new SelectTeacherVo();
            teacherVos.add(selectTeacherVo);
            return Result.success(new QueryReturnDate(paginationDate, teacherVos));
        }
        //当前页大于总页数
        if (PaginationUtils.isValid(paginationDate))
            return Result.error("当前页大于总页数");
        return Result.success(new QueryReturnDate(paginationDate, teacherVos));
    }

    //管理员修改密码
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    public synchronized Result adminUpdatePass(UpdatePassWordBo updatePassWordBo, UserEntity userEntity) {
        //数据校验
        DataCheckUtils.isNotBlank(userEntity.getId(), "ID不能为空!");
        DataCheckUtils.isNotBlank(updatePassWordBo.getPassword(),"密码不能为空");
        DataCheckUtils.isNotBlank(updatePassWordBo.getNewPassword(), "新密码不能为空!");
        DataCheckUtils.isValid(updatePassWordBo.getNewPassword().matches("^.{6,16}$"), "新密码格式错误!");
        DataCheckUtils.isNotBlank(updatePassWordBo.getConfirmPassword(),"确认密码不能为空");
       // DataCheckUtils.isValid(adminUpdatePassWordBo.getConfirmPassword().matches(" ^[A-Za-z0-9`~!@#$%^&*()_+<>?|,./]{6,16}"), "密码格式错误!");

        //指定ID查询管理员用户
        String id= userEntity.getId();
        System.out.println(id);
        String userPassword = updatePassWordBo.getPassword();
        String newPassword = updatePassWordBo.getNewPassword();
        String confirmPassword = updatePassWordBo.getConfirmPassword();

        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getId, userEntity.getId()).eq(UserEntity::getRoleType,RoleTypeEnum.ADMIN.getKey())
                .select(UserEntity::getPassword, UserEntity::getId);
        UserEntity user = userMapper.selectOne(sectionQueryWrapper);
        System.out.println(userPassword);
        System.out.println(user.getPassword());
        System.out.println(userPassword.equals(user.getPassword()));
        if (user == null) {
            return Result.error("未找到该管理员用户");
        }else {
            DataCheckUtils.isValid(userPassword.equals(user.getPassword()), "原密码不正确");
            DataCheckUtils.isValid(newPassword.equals(confirmPassword),"两次新密码不一致");
            DataCheckUtils.isNotValid(newPassword.equals(user.getPassword()),"新密码不能和原密码一致");
        }

        UserEntity updateUser = new UserEntity();
        updateUser.setPassword(updatePassWordBo.getNewPassword());
        updateUser.setUpdateBy(userEntity.getId());
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getId, userEntity.getId());
        int row = userMapper.update(updateUser, updateWrapper);

        //判断插入结果
        if (row == 0) {
            return Result.error("修改密码失败");
        }
        return Result.success();
    }




    //学生修改密码
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    public synchronized Result studentUpdatePass(UpdatePassWordBo updatePassWordBo, UserEntity userEntity) {
        //数据校验
        DataCheckUtils.isNotBlank(userEntity.getId(), "ID不能为空!");
        DataCheckUtils.isNotBlank(updatePassWordBo.getPassword(),"密码不能为空");
        DataCheckUtils.isNotBlank(updatePassWordBo.getNewPassword(), "新密码不能为空!");
        DataCheckUtils.isValid(updatePassWordBo.getNewPassword().matches("^.{6,16}$"), "新密码格式错误!");
        DataCheckUtils.isNotBlank(updatePassWordBo.getConfirmPassword(),"确认密码不能为空");


        //指定ID查询管理员用户
        String id= userEntity.getId();
        String userPassword = updatePassWordBo.getPassword();
        String newPassword = updatePassWordBo.getNewPassword();
        String confirmPassword = updatePassWordBo.getConfirmPassword();

        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getId, userEntity.getId()).eq(UserEntity::getRoleType,RoleTypeEnum.STUDENT.getKey())
                .select(UserEntity::getPassword, UserEntity::getId);
        UserEntity user = userMapper.selectOne(sectionQueryWrapper);
        System.out.println(userPassword);
        System.out.println(user.getPassword());
        System.out.println(userPassword.equals(user.getPassword()));
        if (user == null) {
            return Result.error("未找到该学生用户");
        }else {
            DataCheckUtils.isValid(userPassword.equals(user.getPassword()), "原密码不正确");
            DataCheckUtils.isValid(newPassword.equals(confirmPassword),"两次新密码不一致");
            DataCheckUtils.isNotValid(newPassword.equals(user.getPassword()),"新密码不能和原密码一致");
        }

        UserEntity updateUser = new UserEntity();
        updateUser.setPassword(updatePassWordBo.getNewPassword());
        updateUser.setUpdateBy(userEntity.getId());
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getId, userEntity.getId());
        int row = userMapper.update(updateUser, updateWrapper);

        //判断插入结果
        if (row == 0) {
            return Result.error("修改密码失败");
        }
        return Result.success();
    }

    //教师修改密码
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    public synchronized Result teacherUpdatePass(UpdatePassWordBo updatePassWordBo, UserEntity userEntity) {
        //数据校验
        DataCheckUtils.isNotBlank(userEntity.getId(), "ID不能为空!");
        DataCheckUtils.isNotBlank(updatePassWordBo.getPassword(),"密码不能为空");
        DataCheckUtils.isNotBlank(updatePassWordBo.getNewPassword(), "新密码不能为空!");
        DataCheckUtils.isValid(updatePassWordBo.getNewPassword().matches("^.{6,16}$"), "新密码格式错误!");
        DataCheckUtils.isNotBlank(updatePassWordBo.getConfirmPassword(),"确认密码不能为空");


        //指定ID查询管理员用户
        String id= userEntity.getId();
        String userPassword = updatePassWordBo.getPassword();
        String newPassword = updatePassWordBo.getNewPassword();
        String confirmPassword = updatePassWordBo.getConfirmPassword();

        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getId, userEntity.getId()).eq(UserEntity::getRoleType,RoleTypeEnum.TEACHER.getKey())
                .select(UserEntity::getPassword, UserEntity::getId);
        UserEntity user = userMapper.selectOne(sectionQueryWrapper);
        System.out.println(userPassword);
        System.out.println(user.getPassword());
        System.out.println(userPassword.equals(user.getPassword()));
        if (user == null) {
            return Result.error("未找到该教师用户");
        }else {
            DataCheckUtils.isValid(userPassword.equals(user.getPassword()), "原密码不正确");
            DataCheckUtils.isValid(newPassword.equals(confirmPassword),"两次新密码不一致");
            DataCheckUtils.isNotValid(newPassword.equals(user.getPassword()),"新密码不能和原密码一致");
        }

        UserEntity updateUser = new UserEntity();
        updateUser.setPassword(updatePassWordBo.getNewPassword());
        updateUser.setUpdateBy(userEntity.getId());
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getId, userEntity.getId());
        int row = userMapper.update(updateUser, updateWrapper);

        //判断插入结果
        if (row == 0) {
            return Result.error("修改密码失败");
        }
        return Result.success();
    }


    //管理员重置密码
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    public synchronized Result adminResetPass(ResetPassBo resetPassBo, UserEntity userEntity) {
        //数据校验
        DataCheckUtils.isNotBlank(resetPassBo.getId(), "ID不能为空!");

        //指定ID查询管理员用户
        String id= resetPassBo.getId();

        QueryWrapper<UserEntity> sectionQueryWrapper = new QueryWrapper<>();
        sectionQueryWrapper.lambda().eq(UserEntity::getId, resetPassBo.getId())
                .select(UserEntity::getIdNo, UserEntity::getId);
        UserEntity user = userMapper.selectOne(sectionQueryWrapper);
        System.out.println(user.getIdNo());
        System.out.println(user.getId());
        if (user == null) {
            return Result.error("未找到该用户");
        }

        UserEntity updateUser = new UserEntity();
        updateUser.setPassword(user.getIdNo().substring(user.getIdNo().length() - 6));
        updateUser.setUpdateBy(resetPassBo.getId());
        UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(UserEntity::getId, resetPassBo.getId());
        int row = userMapper.update(updateUser, updateWrapper);

        //判断插入结果
        if (row == 0) {
            return Result.error("重置密码失败");
        }
        return Result.success();
    }


}
